package org.ykh.service.exception;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * @author ykh
 */
//当前异常被抛出时，设置指定响应码，默认为500
@ResponseStatus
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
public class BusinessException extends RuntimeException{
    private String code;
    private String msg;
    private HttpStatus httpState;

    public BusinessException() {
    }

    public BusinessException(Throwable cause) {
        super(cause);
    }

    public BusinessException(String message, String code) {
        this.code = code;
        this.msg = message;
    }

    public BusinessException(String code, String msg, HttpStatus httpState) {
        this(msg,code);
        this.httpState = httpState;
    }
}
